package com.lin.filegraph.utils.parser.node;

import com.lin.filegraph.utils.parser.astutil.ASTFileASTRequestor;
import com.lin.filegraph.utils.methoddg.MethodGraph;
import com.lin.filegraph.utils.compdg.ComponentGraph;
import com.lin.filegraph.utils.filedg.FileGraph;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: linhuaixu
 * @time: 2023/5/18 10:07
 */

public class JProjectNode extends JTreeNode {
    private String projectName;
    private String projectPath;
    private String versionNo;
    private List<String> pkgNames = new ArrayList<>();
    ASTFileASTRequestor astFileASTRequestor = null;
    private MethodGraph mdg = null;
    private FileGraph fdg = null;
    private ComponentGraph compDG = null;

    public JProjectNode(String projectName, String versionNo, String strProjectPath,
                        ASTFileASTRequestor astFileASTRequestor) {
        super(strProjectPath, null);
        this.projectName = projectName;
        this.versionNo = versionNo;
        this.astFileASTRequestor = astFileASTRequestor;
    }

    public JProjectNode(String filePath, String projectName, String versionNo) {
        super(filePath, null);
        this.projectName = projectName;
        this.versionNo = versionNo;
    }

    public ASTFileASTRequestor getAstFileASTRequestor() {
        return astFileASTRequestor;
    }

    public List<JDirectoryNode> getAllDirectories() {
        List<JDirectoryNode> dirList = new ArrayList<JDirectoryNode>();
        List<? extends JTreeNode> tempList = super.getChildrenNodeList();
        for (JTreeNode basedNode : tempList) {
            if (basedNode instanceof JDirectoryNode) {
                JDirectoryNode dir = (JDirectoryNode) basedNode;
                dirList.add(dir);
            }
        }
        return dirList;
    }

    @Override
    public String toString() {
        return "[ProjectNode] " + projectName + " " + versionNo;
    }

    /**
     * @return the pkgNames
     */
    public List<String> getPkgNames() {
        return pkgNames;
    }

    /**
     * @return the mdg
     */
    public MethodGraph getMdg() {
        return mdg;
    }

    public void setProjectPath(String projectPath) {
        this.projectPath = projectPath;
    }
    public String getProjectPath() {
        return this.projectPath;
    }
    /**
     * @param mdg the mdg to set
     */
    public void setMdg(MethodGraph mdg) {
        this.mdg = mdg;
    }

    /**
     * @return the fdg
     */
    public FileGraph getFdg() {
        return fdg;
    }

    /**
     * @param fdg the fdg to set
     */
    public void setFdg(FileGraph fdg) {
        this.fdg = fdg;
    }



    /**
     * @return the compDG
     */
    public ComponentGraph getCompDG() {
        return compDG;
    }

    public void setCompDG(ComponentGraph compDG) {
        this.compDG = compDG;
    }




    public String getProjectName() {
        return projectName;
    }

}

